Algorithm
A random hashing-based method for frequent elements problem.
Solves point query problem: given any value , let be the number of times appears in the stream.
Goal: return estimate such that .
Solving Frequent items: return all items for which .
(assume access to a uniformly random hash function)
Count-Min Update:
- Choose random hash function mapping to
- For : given item , set
return estimate
- always have
\mathbf{A}[h(v)] = f(v) + \sum_{y \neq v} \mathbb{1}[h(y)=h(v)]\cdot f(y)$$ (this rightward summation term is error in frequency estimate)
Expected error is
$$ \begin{aligned}
\mathbb{E}\left[\sum_{y \neq v} \mathbb{1}[h(y)=h(v)]\cdot f(y)\right] = \sum_{y \neq v} \mathbb{E}[\mathbb{1}[h(y)=h(v)]\cdot f(y)] \\
= \sum_{y \neq v} f(y) \mathbb{E}[\mathbb{1}[h(y)=h(v)]] = \frac{1}{m} \sum_{y \neq v} f(y) \leq \frac{n}{m}
\end{aligned}
ParseError: Can't use function '$' in math mode at position 74:
…h(v)]\cdot f(y)$̲$ (this rightwa…
Bound of probability of error ?
Use Markov's inequality:
Claim: for any , with probability at least ,
To solve point query with error , set .
length arrays
Estimate with .
- for every and and , we know that with probability ,
#incomplete
See also
- (ε, k)-Frequent Items Problem
References
- G. Cormode and S. Muthukrishnan, “An improved data stream summary: the count-min sketch and its applications,” Journal of Algorithms, vol. 55, no. 1, pp. 58–75, Apr. 2005, doi: 10.1016/j.jalgor.2003.12.001.
- https://www.chrismusco.com/amlds2023/notes/lecture01.html#Count-Min_Sketch
- https://www.chrismusco.com/amlds2023/lectures/lec1_annotated.pdf ^4e6aed